package com.netbliz.common.util;

public class StringUtil {
	/**
	 * String解析为int，错误返回-1
	 * @param str
	 * @return
	 */
	public static int parseInt(String str) {
		int result = -1;
		if(str == null || str.length() == 0 || "NaN".equals(str))
			return result;
		try {
			result = Integer.parseInt(str);
		}catch(NumberFormatException e) {
		}
		return result;
	}
	
	public static Double parseDouble(String str) {
		Double result = 0.0;
		if(str == null || str.length() == 0 || "NaN".equals(str))
			return result;
		try {
			result = Double.parseDouble(str);
		}catch(NumberFormatException e) {
		}
		return result;
	}
}
